package org.shuma.goods.controller;

import com.alipay.sofa.runtime.api.annotation.SofaReference;
import com.alipay.sofa.runtime.api.annotation.SofaReferenceBinding;
import com.shuma.domain.pojo.Result;
import org.shuma.goods.contant.UserConstant;
import org.shuma.supplier.facade.SupplierFacade;
import org.shuma.user.vo.UserVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

/**
 * @author :Wjh
 * @since :2024/6/20 下午8:51
 */

@Validated
@RestController
@RequestMapping("/supplier")
public class SupplierController {
    @SofaReference(interfaceType = SupplierFacade.class, uniqueId = "${service.supplier.unique.id}",
            binding = @SofaReferenceBinding(bindingType = "bolt"))

    SupplierFacade supplierService;

    @GetMapping("/info")
    public Result getSupplier(@RequestParam @NotNull String supplierName,@RequestAttribute("userInfo") UserVo userVo){
        if (userVo.getUserRole() != UserConstant.USER_STATUS) {
            return new Result().error("该角色无权限");
        }
        return supplierService.searchSupplier(supplierName);
    }
}
